package jiejie.jianzhioffer;

public class offer04 {
    public static void main(String[] args) {

    }
    /**
     * 二维数组查找
     * @param matrix
     * @param target
     * @return
     */
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix==null || matrix.length==0 || matrix[0].length==0)
            return false;
        int hs=matrix.length;
        int ls=matrix[0].length;
        int i=0;
        int j=ls-1;
        while(i<hs && j>=0){
            if(matrix[i][j]==target)
                return true;
            else if(matrix[i][j]>target)
                j--;
            else
                i++;
        }
        return false;
    }
}